using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration.Conventions;
using InduMall.Core.Models.Mapping;
using InduMall.Core.Models;

namespace InduMall.Data.Models
{
    public partial class MallContext : DbContext
    {
        static MallContext()
        {
            Database.SetInitializer<MallContext>(null);
        }

        public MallContext()
            : base("Name=MallContext")
        {
        }

        public DbSet<Address> Addresses { get; set; }
        public DbSet<CartItem> CartItems { get; set; }
        public DbSet<Category> Categories { get; set; }
        public DbSet<DiscountProduct> DiscountProducts { get; set; }
        public DbSet<Download> Downloads { get; set; }
        public DbSet<InformationPage> InformationPages { get; set; }
        public DbSet<Order> Orders { get; set; }
        public DbSet<OrderProduct> OrderProducts { get; set; }
        public DbSet<Product> Products { get; set; }
        public DbSet<ProductAttribute> ProductAttributes { get; set; }
        public DbSet<ProductImage> ProductImages { get; set; }
        public DbSet<ProductStock> ProductStocks { get; set; }
        public DbSet<RecommendProduct> RecommendProducts { get; set; }
        public DbSet<ShoppingCart> ShoppingCarts { get; set; }
        public DbSet<Specification> Specifications { get; set; }
        public DbSet<StockStatu> StockStatus { get; set; }
        public DbSet<User> Users { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
            modelBuilder.Configurations.Add(new AddressMap());
            modelBuilder.Configurations.Add(new CartItemMap());
            modelBuilder.Configurations.Add(new CategoryMap());
            modelBuilder.Configurations.Add(new DiscountProductMap());
            modelBuilder.Configurations.Add(new DownloadMap());
            modelBuilder.Configurations.Add(new InformationPageMap());
            modelBuilder.Configurations.Add(new OrderMap());
            modelBuilder.Configurations.Add(new OrderProductMap());
            modelBuilder.Configurations.Add(new ProductMap());
            modelBuilder.Configurations.Add(new ProductAttributeMap());
            modelBuilder.Configurations.Add(new ProductImageMap());
            modelBuilder.Configurations.Add(new ProductStockMap());
            modelBuilder.Configurations.Add(new RecommendProductMap());
            modelBuilder.Configurations.Add(new ShoppingCartMap());
            modelBuilder.Configurations.Add(new SpecificationMap());
            modelBuilder.Configurations.Add(new StockStatuMap());
            modelBuilder.Configurations.Add(new UserMap());
        }
    }
}
